package com.summer.core.web.bean;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;

import com.summer.core.common.BeanName;
import com.summer.core.entity.BaseBean;

/**
 * 菜单实体
 * 
 * @author wwwlike
 * 
 */
@Entity
@BeanName("菜单")
public class Menu extends BaseBean {
	private static final long serialVersionUID = -2056510192706564345L;
	private int sort;

	// 菜单标题
	private String title;
	// 打开路径
	private String url;
	// 完整代码路径
	private String tcode;
	// 完成名称路径
	private String tname;
	private String icon_close;
	private String icon_open;
	private String remark;
	// 是否常用菜单
	private boolean common;
	// 打开方式
	private String target;
	
	private Menu parent;// 上级分类;
	
	private Set<Menu> children;

	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	
	@ManyToOne(cascade=CascadeType.REFRESH,fetch = FetchType.LAZY)
	@JoinColumn(name = "parentid")
	public Menu getParent() {
		return parent;
	}
	   
	
	public void setParent(Menu parent) {
		this.parent = parent;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getTcode() {
		return tcode;
	}

	public void setTcode(String tcode) {
		this.tcode = tcode;
	}

	public String getTname() {
		return tname;
	}

	public void setTname(String tname) {
		this.tname = tname;
	}

	public String getIcon_close() {
		return icon_close;
	}

	public void setIcon_close(String iconClose) {
		icon_close = iconClose;
	}

	public String getIcon_open() {
		return icon_open;
	}

	public void setIcon_open(String iconOpen) {
		icon_open = iconOpen;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public boolean isCommon() {
		return common;
	}

	public void setCommon(boolean common) {
		this.common = common;
	}

	@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
	@OrderBy("sort asc")
	public Set<Menu> getChildren() {
		return children;
	}

	public void setChildren(Set<Menu> children) {
		this.children = children;
	}

	
	
	
	
	
}
